from python算法.Graph.Ljt import graph
# class solution(graph):
#     def __init__(self,file=None):
#         super().__init__(file)
#         self.__order = []
#         self.__visited = [False]*7
#
#     def GetDfsOrder(self):
#         self.__dfs(0)
#         return self.__order
#
#     def __dfs(self,v):
#         self.__order.append(v)
#         self.__visited[v] = True
#         for i in self.adjacentVertices(v):
#             if  not self.__visited[i]:
#                 self.__dfs(i)
class solution():
    def __init__(self,V):
        self.__order = []
        self.__visited = [False]*V

    def GetDfsOrder(self,G):
        self.__dfs(G,0)
        return self.__order

    def __dfs(self,G,v):
        self.__order.append(v)
        self.__visited[v] = True
        for i in G.adjacentVertices(v):
            if  not self.__visited[i]:
                self.__dfs(G,i)

if __name__ == '__main__':
    g = graph(r"D:\tensorflow2_pytorch\python算法\Graph\GV.txt")
    g.readGraph()
    V = g.getV
    s = solution(V)
    print(s.GetDfsOrder(g))



